﻿using NPOI.HSSF.Util;
using NPOI.SS.UserModel;

namespace tools.office.npoi
{
    /// <summary>
    /// 字体帮助类
    /// </summary>
    public static class FontHelper
    {
        /// <summary>
        /// 创建字体
        /// </summary>
        /// <param name="workbook">工作簿实例</param>
        /// <param name="fontName">字体名称（默认 => 等线）</param>
        /// <param name="fontSize">字体大小（默认 => 11）</param>
        /// <param name="isBold">是否加粗（默认 => false）</param>
        /// <param name="fontColor">字体颜色（默认 => Black）</param>
        /// <returns>字体实例</returns>
        public static IFont GetFont(
            IWorkbook workbook, 
            string fontName = "等线", 
            double fontSize = 11, 
            bool isBold = false, 
            short fontColor = HSSFColor.Black.Index)
        {
            IFont font = workbook.CreateFont();
            font.FontName = fontName;
            font.FontHeightInPoints = fontSize;
            font.IsBold = isBold;
            font.Color = fontColor;

            return font;
        }
    }
}
